#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "color_convert.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
//    方式一：注册定义好的对象到 QML
//    MyQmlClass myQmlImp;
//    engine.rootContext()->setContextProperty("myQmlImp", &myQmlImp);
//    方式二：注册类到 QML 对象
    qmlRegisterType<color_convert>("com.company.color_convert", 1, 0, "Color_Convert");

    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);
    engine.loadFromModule("color_convert", "Main");

    return app.exec();
}
